package top.caoayu.common.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import top.caoayu.common.config.filter.RequestResponseLoggingFilter;
import top.caoayu.common.config.filter.TransactionFilter;

@Component
@Slf4j
public class RegisterFilterBeanConfig {
    @Bean
    public FilterRegistrationBean<TransactionFilter> transactionFilter(){
        FilterRegistrationBean<TransactionFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new TransactionFilter());
        registrationBean.setOrder(2);
        return registrationBean;
    }
    @Bean
    public FilterRegistrationBean<RequestResponseLoggingFilter> loggingFilter(){
        FilterRegistrationBean<RequestResponseLoggingFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new RequestResponseLoggingFilter());
        registrationBean.setOrder(1);
        return registrationBean;
    }

}
